import request from '@/utils/request'

export const dictService = {
  // 获取字典列表
  getDicts(params) {
    return request({
      url: '/dicts',
      method: 'get',
      params
    })
  },
  
  // 获取字典详情
  getDictDetail(id) {
    return request({
      url: `/dicts/${id}`,
      method: 'get'
    })
  },
  
  // 创建字典
  createDict(data) {
    return request({
      url: '/dicts',
      method: 'post',
      data
    })
  },
  
  // 更新字典
  updateDict(id, data) {
    return request({
      url: `/dicts/${id}`,
      method: 'put',
      data
    })
  },
  
  // 删除字典
  deleteDict(id) {
    return request({
      url: `/dicts/${id}`,
      method: 'delete'
    })
  },
  
  // 获取字典项
  getDictItems(type) {
    return request({
      url: `/dicts/items/${type}`,
      method: 'get'
    })
  }
}